class Solution(object):
    def reconstructQueue(self, people):
        """
        :type people: List[List[int]]
        :rtype: List[List[int]]
        """     
        people = sorted(people, key=lambda x:(-x[0], x[1]))

        res = []
        for p in people:
            k = p[1]
            if k > res:
                res.append(p)
            else:
                res.insert(k, p)
        return res
